from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import gettext_lazy as _

from .models import Level, Identity, CustomUser


@admin.register(Level)
class LevelAdmin(admin.ModelAdmin):
    list_display = ('value', 'color',
                    # 'font_color',
                    )


@admin.register(Identity)
class IdentityAdmin(admin.ModelAdmin):
    list_display = ('name', 'level')
    list_editable = ('level',)


@admin.register(CustomUser)
class CustomUserAdmin(UserAdmin):
    fieldsets = (
        (None, {"fields": ("username", "password", "image", "background", "homepage")}),
        (_("Personal info"), {"fields": ("first_name", "last_name", "email")}),
        (
            _("Permissions"),
            {
                "fields": (
                    "is_active",
                    "is_staff",
                    "is_superuser",
                    "groups",
                    "user_permissions",
                ),
            },
        ),
        (_("Important dates"), {"fields": ("last_login", "date_joined")}),
        (
            '教徒信息',
            {
                'fields': (
                    'identity',
                )
            }
        )
    )
    list_display = ('username', 'identity', 'is_staff', 'is_superuser')
    list_editable = ('identity', 'is_staff', 'is_superuser')
    ordering = None
